import React from 'react';
import { Switch, Route, Redirect, routerRedux } from 'dva/router'
import PropTypes from 'prop-types'
import dynamic from 'dva/dynamic'
import App from './routes/app';

const { ConnectedRouter } = routerRedux

const Routers = function ({ history, app }) {
  const error = dynamic({
    app,
    // component: () => import('./routes/error/'),
  })
  // 基础中心
  const basic=[
     // 渠道管理
    {
      path: '/basicCenter/channelManage',
      component: () => import('./routes/basicCenter/channelManage'),
      models: () => [import('./models/basicCenter/channelManage')],
    },
    {
      path: '/basicCenter/channelManageDetail',
      component: () => import('./routes/basicCenter/channelManage/channelManageDetail'),
      models: () => [import('./models/basicCenter/channelManage/channelManageDetail')],
    },
    {
      path: '/basicCenter/notice',
      component: () => import('./routes/basicCenter/channelManage/notice'),
      // models: () => [import('./models/basicCenter/channelManage/channelManageDetail')],
    },
    // // 商户管理
    // {
    //   path: '/merechant',
    //   component: () => import('./routes/basicCenter/merechant'),
    // },
    // // 会员管理
    // {
    //   path: '/member',
    //   component: () => import('./routes/basicCenter/member'),
    // },
    // // 开户管理
    // {
    //   path: '/apply',
    //   component: () => import('./routes/basicCenter/apply'),
    // }
  ]
  // // 交易管理
  // const deal=[
  //   // 商户订单
  //   {
  //     path: '/order/merchantOrderPage',
  //     component: () => import('./routes/order/merchantOrderPage'),
  //   },
  //   // 平台订单
  //   {
  //     path: '/order/plantformOrderPage',
  //     component: () => import('./routes/order/plantformOrderPage'),
  //   },
  //   // 退款订单
  //   {
  //     path: '/order/refundOrderPage',
  //     component: () => import('./routes/order/refundOrderPage'),
  //   }
  // ]
  // // 财务管理
  // const finance=[
  //   // 平台账户管理
  //   {
  //     path: '/account/plantformAccountPage',
  //     component: () => import('./routes/account/plantformAccountPage'),
  //   },
  //   // 渠道账户管理
  //   {
  //     path: '/account/aibankAccountPage',
  //     component: () => import('./routes/account/aibankAccountPage'),
  //   },
  //   // 账户调账管理
  //   {
  //     path: '/adjustment/adjustmentPage',
  //     component: () => import('./routes/adjustment/adjustmentPage'),
  //   }
  // ]
  // // 清结算管理
  // const settlement=[
  //   // 账户试算平衡
  //   {
  //     path: '/trial/trialBalancingPage',
  //     component: () => import('./routes/trial/trialBalancingPage'),
  //   },
  //   // 内部账户核对
  //   {
  //     path: '/internal/internalAccountReconciliationPage',
  //     component: () => import('./routes/internal/internalAccountReconciliationPage'),
  //   },
  //   // 外部账户核对
  //   {
  //     path: '/external/externalAccountReconciliationPage',
  //     component: () => import('./routes/external/externalAccountReconciliationPage'),
  //   },
  //    // 交易对账清单
  //    {
  //     path: '/trade/reconciliationTradePage',
  //     component: () => import('./routes/trade/reconciliationTradePage'),
  //   },
  //   // 账户维度对账结果
  //   {
  //     path: '/reconciliationResult/acctReconciliationResultPage',
  //     component: () => import('./routes/reconciliationResult/acctReconciliationResultPage'),
  //   },
  //   // 账单维度对账结果
  //   {
  //     path: '/reconciliationResult/billReconciliationResultPage',
  //     component: () => import('./routes/reconciliationResult/billReconciliationResultPage'),
  //   },
  //    // 差错处理记录
  //    {
  //     path: '/mistake/mistakeDealRecordPage',
  //     component: () => import('./routes/mistake/mistakeDealRecordPage'),
  //   }
  // ]
  // // 系统设置
  // const setting=[
  //   // 短信发送记录
  //   {
  //     path: '/smsSendingRecord/smsSendingRecordPage',
  //     component: () => import('./routes/smsSendingRecord/smsSendingRecordPage'),
  //   },
  //   // 收银台设置
  //   {
  //     path: '/cashier/cashierPage',
  //     component: () => import('./routes/cashier/cashierPage'),
  //   },
  //   // 银行信息管理
  //   {
  //     path: '/bankPaychannel/bankPaychannelPage',
  //     component: () => import('./routes/bankPaychannel/bankPaychannelPage'),
  //   },
  //     // 公告信息管理
  //     {
  //     path: '/notice/noticePage',
  //     component: () => import('./routes/notice/noticePage'),
  //   },
  //   // 系统收发记录
  //   {
  //     path: '/sendingRecord/sendingRecordPage',
  //     component: () => import('./routes/sendingRecord/sendingRecordPage'),
  //   },
  //   // 系统日切记录
  //   {
  //     path: '/tradeDayCut/query',
  //     component: () => import('./routes/tradeDayCut/query'),
  //   }
  // ]
  // const routes = [basic,deal,finance,settlement,setting];
  const routes = basic;
  return (
    <ConnectedRouter history={history}>
      <App>
        <Switch>
          <Route exact path="/" render={() => (<Redirect to="/basicCenter/channelManage" />)} />
          {
            routes.map(({ path, ...dynamics }, key) => (
              <Route key={key}
                exact
                path={path}
                component={dynamic({
                  app,
                  ...dynamics,
                })}
              />
            ))
          }
          <Route component={error} />
        </Switch>
      </App>
    </ConnectedRouter>
  )

}

Routers.propTypes = {
  history: PropTypes.object,
  app: PropTypes.object,
}

export default Routers
